<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			//输入：nums = [5,7,7,8,8,10], target = 8
			//输出：[3,4]
			function searchGeTarget(nums, target){
				let left = 0;
				let right = nums.length - 1;
				while (left <= right){
					let mid = Math.floor((left + right)/2);
					if(nums[mid] == target){
						return mid;
					}else if (nums[mid] >= target){
						right = mid - 1;
					}else {
						left = mid + 1;
					}
				}
				return -1;
			}
			function main(arr,target){
				let m = searchGeTarget(arr,target);
				let l = -1;
				let r = -1;
				for(let i = m;i>=0;i--){
					if(arr[i] == target){
						l = i
					}
				}
				for(let i = m;i<=arr.length-1;i++){
					if(arr[i] == target){
						r = i
					}
				}
				return [l,r];
			}
			console.log(main([5,7,7,8,8,10],8));
		</script>
	</body>
</html>
